/**
 *******************************************************************************
 * @FileName  : mesh_security.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-05-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */

#ifndef MESH_SECURITY_H_
#define MESH_SECURITY_H_

#include "utils/defs_types.h"

#define MESH_SEC_TEST_EN   0

typedef struct{
	const void  *pData;
	uint32_t     len;
}DataSeg_t;

uint8_t MESH_AesCmac(uint8_t mac[16], DataSeg_t *pSeg, uint32_t segNum, uint8_t key[16]);
uint8_t MESH_AesCmacOne(uint8_t mac[16], uint8_t *pData, uint32_t len, uint8_t key[16]);

uint8_t MESH_S1(uint8_t salt[16], uint8_t *in, uint32_t len);
bool_t  MESH_K1(uint8_t out[16], uint8_t salt[16], uint8_t *N, uint32_t nLen, uint8_t *P, uint32_t pLen);
uint8_t MESH_K2(uint8_t netId[1], uint8_t encKey[16], uint8_t privKey[16], uint8_t N[16], uint8_t *P, uint32_t pLen);
uint8_t MESH_K3(uint8_t out[16], uint8_t N[16]);
uint8_t MESH_K4(uint8_t out[16], uint8_t N[16]);

#if MESH_SEC_TEST_EN
void MESH_SecurityTest(void);
#endif

#endif /* MESH_SECURITY_H_ */
